package com.kedi.homeservicecenter.controller;

import com.kedi.homeservicecenter.service.OpusePraColService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
* 方法实现说明   作品点赞和收藏+1
* @author      ytw
*@param
* @return
* @exception
* @date        2019/7/12 9:47
*/

@RestController
public class OpusPraColController {
    @Autowired
    OpusePraColService opusePraColService;

        /**
        * 方法实现说明  点赞+1
        * @author      ytw
        * @param
        * @return
        * @exception
        * @date        2019/7/12 9:48
        */
        @RequestMapping(value="oldfile/updatePraise")
        public int increasePraise(@RequestParam("opusid") Integer opusid,@RequestParam("puserid")Integer puserid){
            if(opusid<0&&puserid<0) {
                throw new RuntimeException("传入的类型为负数");
            }
            Map map = opusePraColService.selectOpusUserId(opusid);
            map.put("opus_id",opusid);
            map.put("p_user_id",puserid);
           return   opusePraColService.updatePraise(map);
        }

        /**
        * 方法实现说明  收藏+1
        * @author      ytw
        *@param
        * @return
        * @exception
        * @date        2019/7/12 9:49
        */
    @RequestMapping("oldfile/updateCollection")
    public int increaseCollection(@RequestParam("opusid") Integer opusid,@RequestParam("puserid")Integer puserid){
        if(opusid<0&&puserid<0) {
            throw new RuntimeException("传入的类型为负数");
        }
        Map map = opusePraColService.selectOpusUserId(opusid);
        map.put("opus_id",opusid);
        map.put("p_user_id",puserid);
        return opusePraColService.updateCollection(map);
    }






}